Условие:Вам даны две матрицы, нужно написать функцию для их умножения. Матрицы могут быть квадратными или прямоугольными.
Решение: Напишем решение на чистом Python
def matrix_multiply(A, B): # Сначала проверим, можем ли мы вообще перемножить эти матрицы if len(A[0]) != len(B): raise ValueError("Number of A columns must equal number of B rows.")
# Инициализируем результирующую матрицу, заполненную нулями result = [[0 for _ in range(len(B[0]))] for _ in range(len(A))]
# Перемножим матрицы for i in range(len(A)): for j in range(len(B[0])): for k in range(len(B)): result[i][j] += A[i][k] * B[k][j]
return result
# Проверим функцию на примере A = [[1, 2, 3], [4, 5, 6]]
B = [[7, 8], [9, 10], [11, 12]]
result = matrix_multiply(A, B) for row in result: print(row)
Условие:Вам даны две матрицы, нужно написать функцию для их умножения. Матрицы могут быть квадратными или прямоугольными.
Решение: Напишем решение на чистом Python
def matrix_multiply(A, B): # Сначала проверим, можем ли мы вообще перемножить эти матрицы if len(A[0]) != len(B): raise ValueError("Number of A columns must equal number of B rows.")
# Инициализируем результирующую матрицу, заполненную нулями result = [[0 for _ in range(len(B[0]))] for _ in range(len(A))]
# Перемножим матрицы for i in range(len(A)): for j in range(len(B[0])): for k in range(len(B)): result[i][j] += A[i][k] * B[k][j]
return result
# Проверим функцию на примере A = [[1, 2, 3], [4, 5, 6]]
B = [[7, 8], [9, 10], [11, 12]]
result = matrix_multiply(A, B) for row in result: print(row)
#программирование #линейная_алгебра
BY Библиотека собеса по Data Science | вопросы с собеседований
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
Tata Power whose core business is to generate, transmit and distribute electricity has made no money to investors in the last one decade. That is a big blunder considering it is one of the largest power generation companies in the country. One of the reasons is the company's huge debt levels which stood at ₹43,559 crore at the end of March 2021 compared to the company’s market capitalisation of ₹44,447 crore.
Telegram auto-delete message, expiring invites, and more
elegram is updating its messaging app with options for auto-deleting messages, expiring invite links, and new unlimited groups, the company shared in a blog post. Much like Signal, Telegram received a burst of new users in the confusion over WhatsApp’s privacy policy and now the company is adopting features that were already part of its competitors’ apps, features which offer more security and privacy. Auto-deleting messages were already possible in Telegram’s encrypted Secret Chats, but this new update for iOS and Android adds the option to make messages disappear in any kind of chat. Auto-delete can be enabled inside of chats, and set to delete either 24 hours or seven days after messages are sent. Auto-delete won’t remove every message though; if a message was sent before the feature was turned on, it’ll stick around. Telegram’s competitors have had similar features: WhatsApp introduced a feature in 2020 and Signal has had disappearing messages since at least 2016.
Библиотека собеса по Data Science | вопросы с собеседований from nl